Skip to content

Remove non-used blocks - #5313

Open
angus-g wants to merge 6 commits into
JHopeCollins/nlvs-hessian-fixfrom
angus-g/4638-remove-blocks
Open

angus-g wants to merge 6 commits into
JHopeCollins/nlvs-hessian-fixfrom
angus-g/4638-remove-blocks

Conversation

@angus-g

@angus-g angus-g commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Description

This excises the NonlinearVariationalSolveBlock, the GenericSolveBlock, and its subclasses the SolveVarFormBlock and ProjectBlock. There's a bit of hackery to make get_solve_blocks kind of still work without fulling threading projector-ness through the solve machinery.

@angus-g angus-g added the base:main Run this PR using a main (dev) build label Aug 3, 2026
@angus-g
angus-g force-pushed the angus-g/4638-project branch 2 times, most recently from 9c2b031 to 77f178f Compare October 19, 2026 03:00
@angus-g
angus-g force-pushed the angus-g/4638-remove-blocks branch from 244e154 to 4865de5 Compare October 19, 2026 03:12
Comment thread firedrake/adjoint_utils/solving.py Outdated
Comment on lines +14 to +15
if issubclass(type(block), CachedSolverBlock)
and not getattr(block, "_is_project", False)

@JHopeCollins JHopeCollins Oct 19, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Firedrake generally views conditionally present attributes as bad code style. is_project should be set on all solver block types if we need to detect it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the mixin is generating a ProjectBlock directly, this is outdated.

@JHopeCollins

Copy link
Copy Markdown
Member

I like that diff line count!

The CachedSolver block can take over the nlvs solver block name now if we are purging the original.

The ProjectBlock was essentially an extension of SolveVarFormBlock that
sets up the mass matrix system for the adjoint machinery. For the
original (forward) project() call, the "proper" form is used, but
the forward solver on the tape uses a simplified mass matrix.

The approach here replicates that behaviour, but it's routed through
the new CachedSolverBlock. As a consequence however, we have annotation
on the Projector factory, which means that adjoint-friendly projection
can occur through either the bare project() call, or by creating a
Projector object.

The SupermeshSolveBlock is actually a standalone object, so we
just create that when SupermeshProjector.project() is called. Again,
this allows for both bare and object-based projection to be taped.

The final case is the "null" project from one function to another
on the same space. This creates an Assigner, and I assume it will "just
work" through the annotation on assign().
@angus-g
angus-g force-pushed the angus-g/4638-project branch from 77f178f to e216e83 Compare November 13, 2026 05:53
The NLVS mixin has a static method _ad_block_type() that determines
what type of block to create on the tape. This is overridden to
ProjectBlock for projection operations. An accompanying test for the
get_solve_blocks() method has been added.
Also adds a test that verifies this actually works.
Here, the top-level annotate_project is acting more like a boundary on
the annotate=False argument.
@angus-g
angus-g force-pushed the angus-g/4638-project branch from 2d7e153 to a0eb14e Compare November 14, 2026 04:23
Now that the original namespace is clear, we can use a more
descriptive name for the block!
@angus-g
angus-g force-pushed the angus-g/4638-remove-blocks branch from 19c9086 to ecd1467 Compare November 14, 2026 04:58
@JHopeCollins
JHopeCollins removed this pull request from stack #5312 November 15, 2026 12:50
Base automatically changed from angus-g/4638-project to JHopeCollins/nlvs-hessian-fix November 15, 2026 12:51

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

base:main Run this PR using a main (dev) build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants